/*
 Copyright (c) [Year] [name of copyright holder]
 [Software Name] is licensed under Mulan PSL v2.
 You can use this software according to the terms and conditions of the Mulan
 PSL v2.
 You may obtain a copy of Mulan PSL v2 at:
          http://license.coscl.org.cn/MulanPSL2
 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 See the Mulan PSL v2 for more details.
*/

#ifndef _1988WJ_PASTECONFIG_HPP_
#define _1988WJ_PASTECONFIG_HPP_

#include "cJSON.h"
#include <fstream>
#include <iostream>

class PasteConfig {
  private:
    /// @brief 配置文件的json对象指针
    cJSON *configJson;

  public:
    PasteConfig();
    ~PasteConfig();

    /**
     * @brief 获取配置项的布尔值
     *
     * 本函数通过给定的键从JSON配置中获取对应的布尔值配置项，并将其值作为布尔类型返回。
     * 如果键或配置JSON为空，或者配置项不存在，或者配置项类型不是布尔类型，则抛出异常。
     *
     * @param key 配置项的键
     * @return true 如果配置项的值为布尔类型且为真
     * @return false 如果配置项的值为布尔类型且为假
     * @throws std::invalid_argument 如果key或configJson为nullptr
     * @throws std::runtime_error 如果指定键的配置项不存在
     * @throws std::invalid_argument 如果配置项存在但不是布尔类型
     */
    bool GetBoolValue(const char *key) const;

    int GetIntValue(const char *key) const;
    std::string GetStrValue(const char *key) const;

    static void CreateDefaultConfig();
};
#endif